package com.ego.controller;

import com.ego.service.GoodsService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author Ares
 * @date 2020-12-4
 */
@Controller
@RequestMapping("/item")
public class GoodsController {

    @Resource
    private GoodsService goodsService;

    @GetMapping("/{id}.html")
    public String getItemPage(@PathVariable Long id, Model model){

        Map<String, Object> modelMap = goodsService.loadModel(id);

        model.addAllAttributes(modelMap);

        goodsService.asyncExecute(id);

        return "item";
    }
}
